﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Proxy;
using Microsoft.TeamFoundation.VersionControl.Client;
using Nablasoft.Console.Utils;
using TfsUtils.Utils;

namespace TfsUtils
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetWindowPosition(0,0); 
            Console.WindowWidth = Console.LargestWindowWidth - 10;
            
            //String path = @"D:\Develop\TestTFs\BuildExtensions";

            //Workstation workstation = Workstation.Current;
            //WorkspaceInfo info = workstation.GetLocalWorkspaceInfo(path);

            //TfsTeamProjectCollection collection = new TfsTeamProjectCollection(info.ServerUri);
            //Workspace ws = info.GetWorkspace(collection);
            //String servername = ws.GetServerItemForLocalItem(path);
            //VersionControlServer vcs = collection.GetService<VersionControlServer>();

            //IEnumerable changesets = null;
            //VersionSpec spec = VersionSpec.ParseSingleSpec("W", ws.OwnerName);

            //WorkspaceVersionSpec wvs = spec as WorkspaceVersionSpec;
            //if (null != wvs && null == wvs.Name)
            //{
            //    spec = new WorkspaceVersionSpec(ws.Name, ws.OwnerName);
            //}
            //changesets = vcs.QueryHistory(servername, VersionSpec.Latest, 0, RecursionType.Full, null,
            //new ChangesetVersionSpec(1), spec, 1, false, false).OfType<Changeset>().ToList();
            //int changesetId = changesets.Cast<Changeset>().First().ChangesetId;

            //AssemblyNumbering asn = new AssemblyNumbering(ws, path);
            //asn.Generate(Path.Combine(path, "AssemblyFileVersion.cs"), 2, 4, 0, "{owner}");

            //Console.WriteLine(changesetId);

            ICommand command = CommandFactory.Parse(args);
            command.Execute();
            Console.ReadKey();
        }
    }
}
